<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="/WEB-INF/tld/pageable.tld" prefix="pageable"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@	page import="com.yaodian100.core.common.utils.ServerValue"%>

<script src="/js/grid.locale-en.js" type="text/javascript"></script>
<script src="/js/jquery.jqGrid.min.js" type="text/javascript" charset="UTF-8"></script>
<link rel="stylesheet" type="text/css" media="screen" href="/css/ui.jqgrid.css" />
<link href="/css/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" media="screen" />

<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<c-rt:set var="tp" value="${pu:pageableTag('tpp', 10, 10)}"/>
<c-rt:set var="hql">
from CouponItem c where c.memberId = ? order by c.startDate desc,c.endDate desc,c.uuid desc
</c-rt:set>
<!-- and c.coupon.status = 0 -->
<c-rt:set var="params" value="${pu:addToList('paras', param.memberId)}"/>
<c-rt:set var="coupons" value="${pu:queryByHql(hql, params, tp)}"/>

<s:actionerror />
<s:actionmessage />
<s:fielderror />
<input type="hidden" name="memberId" value="${memberId}"/>
<table class="tb-1" width="100%">
	<thead>
		<tr>
			<th>Coupon名称</th>
			<th>Code</th>
			<th>面额</th>
			<th>效期</th>
			<th>状态／订单号</th>
		</tr>
	</thead>
	<tbody>
		<c-rt:forEach items="${coupons}" var="coupons" varStatus="rows_index">
			<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
				<td>${coupons.coupon.name }</td>
				<td><a href="javascript:doAR('<c-rt:url value="/json/couponLogs.do?couponCode=${coupons.code}"/>', 'dialog');openDialog('coupon消费纪录',null,700,300)">${coupons.code}</a></td>
				<td>${coupons.coupon.faceValue}</td>
				<td>
					<fmt-rt:formatDate value="${coupons.startDate}" pattern="yyyy-MM-dd"/> ~ 
					<fmt-rt:formatDate value="${coupons.endDate}" pattern="yyyy-MM-dd"/> 
				</td>
				<td>
					<c-rt:choose>
						<c-rt:when test="${not empty coupons.orderId}">
							${coupons.orderId}
						</c-rt:when>
						<c-rt:otherwise>
							未使用
						</c-rt:otherwise>
					</c-rt:choose>
				</td>
			</tr>
		</c-rt:forEach>
	</tbody>
</table>
<pageable:Pageable url="${midContextPath}/member/searchCoupons.do" escapeparams="AJAX,refreshZone" parameter="AJAX=true&refreshZone=tabs-6" formname="NewCouponForm" key="tpp"></pageable:Pageable>
